Repository navigation
Conversation
Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
|
@copilot the idea is not to inline such system expression, instead just compile fast them, without cost of conversion into LightExpression+conversion... But just in case, please check #558 starting from the Expression.cs changes which also uses/implements this feature. Summarize what and how 558 use this feature for. |
PR #558’s Expression.cs change infers the invoke return type from an |
|
I do not see a reason to call Compile instead of CompileFast, |
|
I agree that we should investigate using CompileFast here: fast-compile the original System lambda using the standard FEC compiler, then invoke the resulting delegate. This matches the requested behavior without converting the tree to LightExpression or inlining it. System's Compile() is not inherently required for correctness here. The architectural consideration is that the LightExpression package currently has no dependency on the standard FEC assembly. Its own CompileFast overloads accept LightExpression trees, so compiling the original System tree directly needs either an explicit dependency on the standard compiler or a bridge. I would prefer an explicit dependency over reflection or duplicated compiler code, if that package dependency is acceptable. For compatibility, the implementation should preserve receiver/argument evaluation order and the point at which the inner tree is compiled. CompileFast with System fallback would keep unsupported inner expressions working; strict compilation of the outer tree should not silently become a new restriction on runtime inner trees. We should also avoid automatically caching the compiled delegate: reducing/compiling a custom tree can have observable side effects or throw, so changing when/how often that happens needs a separate decision. Recommendation: yes, work on this once the dependency approach is agreed. Keep it focused on compiling and invoking the original System tree, add regression tests for argument order, exceptions, captured values and unsupported-inner fallback, and measure inner compilation plus repeated outer invocation against the current Compile() path. There are no new performance measurements behind this recommendation yet. |
LightExpression invocation targets can now be constants containing
System.Linq.Expressions.LambdaExpressionvalues. The compiler compiles and invokes these targets through its existing lambda paths.Changes
Example